<?php 
defined('IN_TS') or die('Access Denied.');

switch($ts){

	case "list":
		$page = tsIntval($_GET['page'],1);
		$url = SITE_URL.'index.php?app=svg&ac=admin&mg=svg&ts=list&page=';
		$lstart = $page*20-20;
		$arrSvg = $new['svg']->findAll('svg',null,'addtime desc',null,$lstart.',20');
		
		$svgNum = $new['svg']->findCount('svg');
		$pageUrl = pagination($svgNum, 20, $page, $url);

		include template('admin/svg_list');
		break;

    case "board":
        $page = tsIntval($_GET['page'],1);
        $url = SITE_URL.'index.php?app=svg&ac=admin&mg=svg&ts=board&page=';
        $lstart = $page*20-20;
        $arrBoard = $new['svg']->findAll('svg_board',null,'addtime desc',null,$lstart.',20');

        $boardNum = $new['svg']->findCount('v');
        $pageUrl = pagination($boardNum, 20, $page, $url);

        print_r($arrBoard);

        include template('admin/board_list');
        break;
		
	//审核通过
	case "isaudit0":
		
		$svgid = tsIntval($_GET['svgid']);
		$strSvg = $new['svg']->find('svg',array('svgid'=>$svgid,));

        $new['svg']->update('svg',array('svgid'=>$svgid,),array('isaudit'=>0,));

        #发送系统消息
        $msg_userid = '0';
        $msg_touserid = $strSvg['userid'];
        $msg_content = '你发布的文章审核通过，快去看看吧^_^ ';
        $msg_url = tsUrl('svg','show',array('id'=>$svgid));
        aac('message')->sendmsg($msg_userid,$msg_touserid,$msg_content,$msg_url);

        #处理积分
        aac('user') -> doScore($TS_URL['app'], $TS_URL['ac'],$TS_URL['mg'],$TS_URL['api'],$TS_URL['ts'],$strSvg['userid']);
		
		qiMsg('操作成功！');
		break;

    #审核不通过
    case "isaudit1":

        $svgid = tsIntval($_GET['svgid']);
        $strSvg = $new['svg']->find('svg',array('svgid'=>$svgid,));

        $new['svg']->update('svg',array('svgid'=>$svgid,),array('isaudit'=>1,));

        #发送系统消息
        $msg_userid = '0';
        $msg_touserid = $strSvg['userid'];
        $msg_content = '你发布的文章审核未通过，快去看看吧^_^ ';
        $msg_url = tsUrl('svg','show',array('id'=>$svgid));
        aac('message')->sendmsg($msg_userid,$msg_touserid,$msg_content,$msg_url);

        #处理积分
        aac('user') -> doScore($TS_URL['app'], $TS_URL['ac'],$TS_URL['mg'],$TS_URL['api'],$TS_URL['ts'],$strSvg['userid']);

        qiMsg('操作成功！');

        break;
		
	//删除 
	case "delete":
	
		$svgid = tsIntval($_GET['svgid']);
		$strSvg = $new['svg']->find('svg',array('svgid'=>$svgid,));
		
		$new['svg']->deletesvg($strSvg);

        #处理积分
		aac('user') -> doScore($TS_URL['app'], $TS_URL['ac'],$TS_URL['mg'],$TS_URL['api'],$TS_URL['ts'],$strSvg['userid']);
		
		#用户记录
		aac('pubs')->addLogs('svg','svgid',$svgid,$TS_USER['userid'],$strSvg['title'],$strSvg['content'],2);
		
		qiMsg('删除成功！');
	
		break;
	
	//推荐
	case "isrecommend":
		
		$svgid = tsIntval($_GET['svgid']);
		$strSvg = $new['svg']->find('svg',array('svgid'=>$svgid,));
		
		if($strSvg['isrecommend']==0){
			$isrecommend = 1;
		}else{
			$isrecommend = 0;
		}

		$new['svg']->update('svg',array('svgid'=>$svgid,),array('isrecommend'=>$isrecommend,));

		#更新项目推荐
		aac('pubs')->upPtableRecommend('svg','svgid',$svgid,$isrecommend);
		
		qiMsg('操作成功！');
		break;

	//置顶
	case "istop":
		
		$svgid = tsIntval($_GET['svgid']);
		$strSvg = $new['svg']->find('svg',array('svgid'=>$svgid,));
		
		if($strSvg['istop']==0){
			$istop = 1;
		}else{
			$istop = 0;
		}

		$new['svg']->update('svg',array('svgid'=>$svgid,),array('istop'=>$istop,));
		
		qiMsg('操作成功！');
		break;

}